package com.idheima.zuoye.zuoye5;

import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;

public class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Student> list = new ArrayList<>();
        ArrayList<Name> list1 = new ArrayList<>();
        for (int i = 1; i <4; i++) {
            System.out.println("请输入第" + i + "个学生的姓名：");
            String name = sc.next();
            System.out.println("请输入第" + i + "个学生的年龄：");
            int age = sc.nextInt();
            list.add(new Student(name, age));
        }


        for (int i = 1; i < 4; i++) {
            System.out.println("请输入第"+ i + "个学生的地址：");
            String address = sc.next();
            list1.add(new Name(address));


        }



        Map<Student, Name> map = new HashMap<>();
        for (int i = 0; i < list.size(); i++) {
            map.put(list.get(i), list1.get(i));
        }
        map.entrySet()
                .stream()
                .distinct()
                .sorted(  (e1,e2)-> e2.getKey().getAge()-e1.getKey().getAge()  )
                .filter(e->e.getKey().getName().startsWith("张"))
                .forEach(e-> System.out.println("姓名："+e.getKey().getName()+"，年龄："+"，居住地："+e.getKey().getAge()+"---"+e));

    }
}
